package com.foo.designpattern.command;

/**
 * com.foo.designpattern.command
 * Created with IntelliJ IDEA.
 * Created by jiang on 2016-04-25 9:42.
 *
 * @Description 顾客：真正的命令发出者
 */
public class Customer {
    private Command command;

    /**
     * 喊过小二来，记录顾客点餐的菜名，然后传达给厨师
     *
     * @param command
     */
    public Customer(Command command) {
        this.command = command;
    }

    /**
     * 将命令的发出与执行分开：点菜和取消点菜
     * 顾客点餐
     *
     * @param food 菜名
     */
    public void order(String food) {
        command.execute(food);
    }

    /**
     * 顾客取消点餐
     *
     * @param food 菜名
     */
    public void unOrder(String food) {
        command.undo(food);
    }
}
